package com.cadre.common.utils.oldutil;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cadre.common.utils.common.SQLFilter;
import org.apache.commons.lang3.StringUtils;

import java.util.LinkedHashMap;
import java.util.Map;

/* loaded from: Query.class */
public class Query<T> extends LinkedHashMap<String, Object> {
    private static final long serialVersionUID = 1;
    private Page<T> page;
    private int currPage;
    private int limit;

    public Query(Map<String, Object> params) {
        this.currPage = 1;
        this.limit = 10;
        putAll(params);
        if (params.get("page") != null) {
            this.currPage = Integer.parseInt((String) params.get("page"));
        }
        if (params.get("limit") != null) {
            this.limit = Integer.parseInt((String) params.get("limit"));
        }
        put("offset", Integer.valueOf((this.currPage - 1) * this.limit));
        put("page", Integer.valueOf(this.currPage));
        put("limit", Integer.valueOf(this.limit));
        String sidx = SQLFilter.sqlInject((String) params.get("sidx"));
        String order = SQLFilter.sqlInject((String) params.get("order"));
        put("sidx", sidx);
        put("order", order);
        this.page = new Page<>(this.currPage, this.limit);
        if (StringUtils.isNotBlank(sidx) && StringUtils.isNotBlank(order)) {
            OrderItem orderItem = new OrderItem();
            orderItem.setAsc("ASC".equalsIgnoreCase(order));
            orderItem.setColumn(sidx);
        }
    }

    public Page<T> getPage() {
        return this.page;
    }

    public int getCurrPage() {
        return this.currPage;
    }

    public int getLimit() {
        return this.limit;
    }
}
